package com.wqm.cn.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
/**
*
*  @author wqm
*/
public class REPORTCRITERIA implements Serializable {

    private static final long serialVersionUID = 1607691493731L;


    /**
    * 主键
    * 查询条件ID
    * isNullAble:0
    */
    private Integer ID;

    /**
    * 数据表栏位名
    * isNullAble:0
    */
    private String cOLUMNNAME;

    /**
    * 比较操作符
    * isNullAble:1
    */
    private String cOMPAREOPERATOR;

    /**
    * 逻辑运算符
    * isNullAble:1
    */
    private String lOGICOPERATOR;

    /**
    * 报表ID
    * isNullAble:0
    */
    private Integer rEPORTID;


    public void setID(Integer ID){this.ID = ID;}

    public Integer getID(){return this.ID;}

    public void setCOLUMNNAME(String cOLUMNNAME){this.cOLUMNNAME = cOLUMNNAME;}

    public String getCOLUMNNAME(){return this.cOLUMNNAME;}

    public void setCOMPAREOPERATOR(String cOMPAREOPERATOR){this.cOMPAREOPERATOR = cOMPAREOPERATOR;}

    public String getCOMPAREOPERATOR(){return this.cOMPAREOPERATOR;}

    public void setLOGICOPERATOR(String lOGICOPERATOR){this.lOGICOPERATOR = lOGICOPERATOR;}

    public String getLOGICOPERATOR(){return this.lOGICOPERATOR;}

    public void setREPORTID(Integer rEPORTID){this.rEPORTID = rEPORTID;}

    public Integer getREPORTID(){return this.rEPORTID;}
    @Override
    public String toString() {
        return "REPORTCRITERIA{" +
                "ID='" + ID + '\'' +
                "cOLUMNNAME='" + cOLUMNNAME + '\'' +
                "cOMPAREOPERATOR='" + cOMPAREOPERATOR + '\'' +
                "lOGICOPERATOR='" + lOGICOPERATOR + '\'' +
                "rEPORTID='" + rEPORTID + '\'' +
            '}';
    }

    public static Builder Build(){return new Builder();}

    public static ConditionBuilder ConditionBuild(){return new ConditionBuilder();}

    public static UpdateBuilder UpdateBuild(){return new UpdateBuilder();}

    public static QueryBuilder QueryBuild(){return new QueryBuilder();}

    public static class UpdateBuilder {

        private REPORTCRITERIA set;

        private ConditionBuilder where;

        public UpdateBuilder set(REPORTCRITERIA set){
            this.set = set;
            return this;
        }

        public REPORTCRITERIA getSet(){
            return this.set;
        }

        public UpdateBuilder where(ConditionBuilder where){
            this.where = where;
            return this;
        }

        public ConditionBuilder getWhere(){
            return this.where;
        }

        public UpdateBuilder build(){
            return this;
        }
    }

    public static class QueryBuilder extends REPORTCRITERIA{
        /**
        * 需要返回的列
        */
        private Map<String,Object> fetchFields;

        public Map<String,Object> getFetchFields(){return this.fetchFields;}

        private List<Integer> IDList;

        public List<Integer> getIDList(){return this.IDList;}

        private Integer IDSt;

        private Integer IDEd;

        public Integer getIDSt(){return this.IDSt;}

        public Integer getIDEd(){return this.IDEd;}

        private List<String> cOLUMNNAMEList;

        public List<String> getCOLUMNNAMEList(){return this.cOLUMNNAMEList;}


        private List<String> fuzzyCOLUMNNAME;

        public List<String> getFuzzyCOLUMNNAME(){return this.fuzzyCOLUMNNAME;}

        private List<String> rightFuzzyCOLUMNNAME;

        public List<String> getRightFuzzyCOLUMNNAME(){return this.rightFuzzyCOLUMNNAME;}
        private List<String> cOMPAREOPERATORList;

        public List<String> getCOMPAREOPERATORList(){return this.cOMPAREOPERATORList;}


        private List<String> fuzzyCOMPAREOPERATOR;

        public List<String> getFuzzyCOMPAREOPERATOR(){return this.fuzzyCOMPAREOPERATOR;}

        private List<String> rightFuzzyCOMPAREOPERATOR;

        public List<String> getRightFuzzyCOMPAREOPERATOR(){return this.rightFuzzyCOMPAREOPERATOR;}
        private List<String> lOGICOPERATORList;

        public List<String> getLOGICOPERATORList(){return this.lOGICOPERATORList;}


        private List<String> fuzzyLOGICOPERATOR;

        public List<String> getFuzzyLOGICOPERATOR(){return this.fuzzyLOGICOPERATOR;}

        private List<String> rightFuzzyLOGICOPERATOR;

        public List<String> getRightFuzzyLOGICOPERATOR(){return this.rightFuzzyLOGICOPERATOR;}
        private List<Integer> rEPORTIDList;

        public List<Integer> getREPORTIDList(){return this.rEPORTIDList;}

        private Integer rEPORTIDSt;

        private Integer rEPORTIDEd;

        public Integer getREPORTIDSt(){return this.rEPORTIDSt;}

        public Integer getREPORTIDEd(){return this.rEPORTIDEd;}

        private QueryBuilder (){
            this.fetchFields = new HashMap<>();
        }

        public QueryBuilder IDBetWeen(Integer IDSt,Integer IDEd){
            this.IDSt = IDSt;
            this.IDEd = IDEd;
            return this;
        }

        public QueryBuilder IDGreaterEqThan(Integer IDSt){
            this.IDSt = IDSt;
            return this;
        }
        public QueryBuilder IDLessEqThan(Integer IDEd){
            this.IDEd = IDEd;
            return this;
        }


        public QueryBuilder ID(Integer ID){
            setID(ID);
            return this;
        }

        public QueryBuilder IDList(Integer ... ID){
            this.IDList = solveNullList(ID);
            return this;
        }

        public QueryBuilder IDList(List<Integer> ID){
            this.IDList = ID;
            return this;
        }

        public QueryBuilder fetchID(){
            setFetchFields("fetchFields","ID");
            return this;
        }

        public QueryBuilder excludeID(){
            setFetchFields("excludeFields","ID");
            return this;
        }

        public QueryBuilder fuzzyCOLUMNNAME (List<String> fuzzyCOLUMNNAME){
            this.fuzzyCOLUMNNAME = fuzzyCOLUMNNAME;
            return this;
        }

        public QueryBuilder fuzzyCOLUMNNAME (String ... fuzzyCOLUMNNAME){
            this.fuzzyCOLUMNNAME = solveNullList(fuzzyCOLUMNNAME);
            return this;
        }

        public QueryBuilder rightFuzzyCOLUMNNAME (List<String> rightFuzzyCOLUMNNAME){
            this.rightFuzzyCOLUMNNAME = rightFuzzyCOLUMNNAME;
            return this;
        }

        public QueryBuilder rightFuzzyCOLUMNNAME (String ... rightFuzzyCOLUMNNAME){
            this.rightFuzzyCOLUMNNAME = solveNullList(rightFuzzyCOLUMNNAME);
            return this;
        }

        public QueryBuilder cOLUMNNAME(String cOLUMNNAME){
            setCOLUMNNAME(cOLUMNNAME);
            return this;
        }

        public QueryBuilder cOLUMNNAMEList(String ... cOLUMNNAME){
            this.cOLUMNNAMEList = solveNullList(cOLUMNNAME);
            return this;
        }

        public QueryBuilder cOLUMNNAMEList(List<String> cOLUMNNAME){
            this.cOLUMNNAMEList = cOLUMNNAME;
            return this;
        }

        public QueryBuilder fetchCOLUMNNAME(){
            setFetchFields("fetchFields","cOLUMNNAME");
            return this;
        }

        public QueryBuilder excludeCOLUMNNAME(){
            setFetchFields("excludeFields","cOLUMNNAME");
            return this;
        }

        public QueryBuilder fuzzyCOMPAREOPERATOR (List<String> fuzzyCOMPAREOPERATOR){
            this.fuzzyCOMPAREOPERATOR = fuzzyCOMPAREOPERATOR;
            return this;
        }

        public QueryBuilder fuzzyCOMPAREOPERATOR (String ... fuzzyCOMPAREOPERATOR){
            this.fuzzyCOMPAREOPERATOR = solveNullList(fuzzyCOMPAREOPERATOR);
            return this;
        }

        public QueryBuilder rightFuzzyCOMPAREOPERATOR (List<String> rightFuzzyCOMPAREOPERATOR){
            this.rightFuzzyCOMPAREOPERATOR = rightFuzzyCOMPAREOPERATOR;
            return this;
        }

        public QueryBuilder rightFuzzyCOMPAREOPERATOR (String ... rightFuzzyCOMPAREOPERATOR){
            this.rightFuzzyCOMPAREOPERATOR = solveNullList(rightFuzzyCOMPAREOPERATOR);
            return this;
        }

        public QueryBuilder cOMPAREOPERATOR(String cOMPAREOPERATOR){
            setCOMPAREOPERATOR(cOMPAREOPERATOR);
            return this;
        }

        public QueryBuilder cOMPAREOPERATORList(String ... cOMPAREOPERATOR){
            this.cOMPAREOPERATORList = solveNullList(cOMPAREOPERATOR);
            return this;
        }

        public QueryBuilder cOMPAREOPERATORList(List<String> cOMPAREOPERATOR){
            this.cOMPAREOPERATORList = cOMPAREOPERATOR;
            return this;
        }

        public QueryBuilder fetchCOMPAREOPERATOR(){
            setFetchFields("fetchFields","cOMPAREOPERATOR");
            return this;
        }

        public QueryBuilder excludeCOMPAREOPERATOR(){
            setFetchFields("excludeFields","cOMPAREOPERATOR");
            return this;
        }

        public QueryBuilder fuzzyLOGICOPERATOR (List<String> fuzzyLOGICOPERATOR){
            this.fuzzyLOGICOPERATOR = fuzzyLOGICOPERATOR;
            return this;
        }

        public QueryBuilder fuzzyLOGICOPERATOR (String ... fuzzyLOGICOPERATOR){
            this.fuzzyLOGICOPERATOR = solveNullList(fuzzyLOGICOPERATOR);
            return this;
        }

        public QueryBuilder rightFuzzyLOGICOPERATOR (List<String> rightFuzzyLOGICOPERATOR){
            this.rightFuzzyLOGICOPERATOR = rightFuzzyLOGICOPERATOR;
            return this;
        }

        public QueryBuilder rightFuzzyLOGICOPERATOR (String ... rightFuzzyLOGICOPERATOR){
            this.rightFuzzyLOGICOPERATOR = solveNullList(rightFuzzyLOGICOPERATOR);
            return this;
        }

        public QueryBuilder lOGICOPERATOR(String lOGICOPERATOR){
            setLOGICOPERATOR(lOGICOPERATOR);
            return this;
        }

        public QueryBuilder lOGICOPERATORList(String ... lOGICOPERATOR){
            this.lOGICOPERATORList = solveNullList(lOGICOPERATOR);
            return this;
        }

        public QueryBuilder lOGICOPERATORList(List<String> lOGICOPERATOR){
            this.lOGICOPERATORList = lOGICOPERATOR;
            return this;
        }

        public QueryBuilder fetchLOGICOPERATOR(){
            setFetchFields("fetchFields","lOGICOPERATOR");
            return this;
        }

        public QueryBuilder excludeLOGICOPERATOR(){
            setFetchFields("excludeFields","lOGICOPERATOR");
            return this;
        }

        public QueryBuilder rEPORTIDBetWeen(Integer rEPORTIDSt,Integer rEPORTIDEd){
            this.rEPORTIDSt = rEPORTIDSt;
            this.rEPORTIDEd = rEPORTIDEd;
            return this;
        }

        public QueryBuilder rEPORTIDGreaterEqThan(Integer rEPORTIDSt){
            this.rEPORTIDSt = rEPORTIDSt;
            return this;
        }
        public QueryBuilder rEPORTIDLessEqThan(Integer rEPORTIDEd){
            this.rEPORTIDEd = rEPORTIDEd;
            return this;
        }


        public QueryBuilder rEPORTID(Integer rEPORTID){
            setREPORTID(rEPORTID);
            return this;
        }

        public QueryBuilder rEPORTIDList(Integer ... rEPORTID){
            this.rEPORTIDList = solveNullList(rEPORTID);
            return this;
        }

        public QueryBuilder rEPORTIDList(List<Integer> rEPORTID){
            this.rEPORTIDList = rEPORTID;
            return this;
        }

        public QueryBuilder fetchREPORTID(){
            setFetchFields("fetchFields","rEPORTID");
            return this;
        }

        public QueryBuilder excludeREPORTID(){
            setFetchFields("excludeFields","rEPORTID");
            return this;
        }
        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public QueryBuilder fetchAll(){
            this.fetchFields.put("AllFields",true);
            return this;
        }

        public QueryBuilder addField(String ... fields){
            List<String> list = new ArrayList<>();
            if (fields != null){
                for (String field : fields){
                    list.add(field);
                }
            }
            this.fetchFields.put("otherFields",list);
            return this;
        }
        @SuppressWarnings("unchecked")
        private void setFetchFields(String key,String val){
            Map<String,Boolean> fields= (Map<String, Boolean>) this.fetchFields.get(key);
            if (fields == null){
                fields = new HashMap<>();
            }
            fields.put(val,true);
            this.fetchFields.put(key,fields);
        }

        public REPORTCRITERIA build(){return this;}
    }


    public static class ConditionBuilder{
        private List<Integer> IDList;

        public List<Integer> getIDList(){return this.IDList;}

        private Integer IDSt;

        private Integer IDEd;

        public Integer getIDSt(){return this.IDSt;}

        public Integer getIDEd(){return this.IDEd;}

        private List<String> cOLUMNNAMEList;

        public List<String> getCOLUMNNAMEList(){return this.cOLUMNNAMEList;}


        private List<String> fuzzyCOLUMNNAME;

        public List<String> getFuzzyCOLUMNNAME(){return this.fuzzyCOLUMNNAME;}

        private List<String> rightFuzzyCOLUMNNAME;

        public List<String> getRightFuzzyCOLUMNNAME(){return this.rightFuzzyCOLUMNNAME;}
        private List<String> cOMPAREOPERATORList;

        public List<String> getCOMPAREOPERATORList(){return this.cOMPAREOPERATORList;}


        private List<String> fuzzyCOMPAREOPERATOR;

        public List<String> getFuzzyCOMPAREOPERATOR(){return this.fuzzyCOMPAREOPERATOR;}

        private List<String> rightFuzzyCOMPAREOPERATOR;

        public List<String> getRightFuzzyCOMPAREOPERATOR(){return this.rightFuzzyCOMPAREOPERATOR;}
        private List<String> lOGICOPERATORList;

        public List<String> getLOGICOPERATORList(){return this.lOGICOPERATORList;}


        private List<String> fuzzyLOGICOPERATOR;

        public List<String> getFuzzyLOGICOPERATOR(){return this.fuzzyLOGICOPERATOR;}

        private List<String> rightFuzzyLOGICOPERATOR;

        public List<String> getRightFuzzyLOGICOPERATOR(){return this.rightFuzzyLOGICOPERATOR;}
        private List<Integer> rEPORTIDList;

        public List<Integer> getREPORTIDList(){return this.rEPORTIDList;}

        private Integer rEPORTIDSt;

        private Integer rEPORTIDEd;

        public Integer getREPORTIDSt(){return this.rEPORTIDSt;}

        public Integer getREPORTIDEd(){return this.rEPORTIDEd;}


        public ConditionBuilder IDBetWeen(Integer IDSt,Integer IDEd){
            this.IDSt = IDSt;
            this.IDEd = IDEd;
            return this;
        }

        public ConditionBuilder IDGreaterEqThan(Integer IDSt){
            this.IDSt = IDSt;
            return this;
        }
        public ConditionBuilder IDLessEqThan(Integer IDEd){
            this.IDEd = IDEd;
            return this;
        }


        public ConditionBuilder IDList(Integer ... ID){
            this.IDList = solveNullList(ID);
            return this;
        }

        public ConditionBuilder IDList(List<Integer> ID){
            this.IDList = ID;
            return this;
        }

        public ConditionBuilder fuzzyCOLUMNNAME (List<String> fuzzyCOLUMNNAME){
            this.fuzzyCOLUMNNAME = fuzzyCOLUMNNAME;
            return this;
        }

        public ConditionBuilder fuzzyCOLUMNNAME (String ... fuzzyCOLUMNNAME){
            this.fuzzyCOLUMNNAME = solveNullList(fuzzyCOLUMNNAME);
            return this;
        }

        public ConditionBuilder rightFuzzyCOLUMNNAME (List<String> rightFuzzyCOLUMNNAME){
            this.rightFuzzyCOLUMNNAME = rightFuzzyCOLUMNNAME;
            return this;
        }

        public ConditionBuilder rightFuzzyCOLUMNNAME (String ... rightFuzzyCOLUMNNAME){
            this.rightFuzzyCOLUMNNAME = solveNullList(rightFuzzyCOLUMNNAME);
            return this;
        }

        public ConditionBuilder cOLUMNNAMEList(String ... cOLUMNNAME){
            this.cOLUMNNAMEList = solveNullList(cOLUMNNAME);
            return this;
        }

        public ConditionBuilder cOLUMNNAMEList(List<String> cOLUMNNAME){
            this.cOLUMNNAMEList = cOLUMNNAME;
            return this;
        }

        public ConditionBuilder fuzzyCOMPAREOPERATOR (List<String> fuzzyCOMPAREOPERATOR){
            this.fuzzyCOMPAREOPERATOR = fuzzyCOMPAREOPERATOR;
            return this;
        }

        public ConditionBuilder fuzzyCOMPAREOPERATOR (String ... fuzzyCOMPAREOPERATOR){
            this.fuzzyCOMPAREOPERATOR = solveNullList(fuzzyCOMPAREOPERATOR);
            return this;
        }

        public ConditionBuilder rightFuzzyCOMPAREOPERATOR (List<String> rightFuzzyCOMPAREOPERATOR){
            this.rightFuzzyCOMPAREOPERATOR = rightFuzzyCOMPAREOPERATOR;
            return this;
        }

        public ConditionBuilder rightFuzzyCOMPAREOPERATOR (String ... rightFuzzyCOMPAREOPERATOR){
            this.rightFuzzyCOMPAREOPERATOR = solveNullList(rightFuzzyCOMPAREOPERATOR);
            return this;
        }

        public ConditionBuilder cOMPAREOPERATORList(String ... cOMPAREOPERATOR){
            this.cOMPAREOPERATORList = solveNullList(cOMPAREOPERATOR);
            return this;
        }

        public ConditionBuilder cOMPAREOPERATORList(List<String> cOMPAREOPERATOR){
            this.cOMPAREOPERATORList = cOMPAREOPERATOR;
            return this;
        }

        public ConditionBuilder fuzzyLOGICOPERATOR (List<String> fuzzyLOGICOPERATOR){
            this.fuzzyLOGICOPERATOR = fuzzyLOGICOPERATOR;
            return this;
        }

        public ConditionBuilder fuzzyLOGICOPERATOR (String ... fuzzyLOGICOPERATOR){
            this.fuzzyLOGICOPERATOR = solveNullList(fuzzyLOGICOPERATOR);
            return this;
        }

        public ConditionBuilder rightFuzzyLOGICOPERATOR (List<String> rightFuzzyLOGICOPERATOR){
            this.rightFuzzyLOGICOPERATOR = rightFuzzyLOGICOPERATOR;
            return this;
        }

        public ConditionBuilder rightFuzzyLOGICOPERATOR (String ... rightFuzzyLOGICOPERATOR){
            this.rightFuzzyLOGICOPERATOR = solveNullList(rightFuzzyLOGICOPERATOR);
            return this;
        }

        public ConditionBuilder lOGICOPERATORList(String ... lOGICOPERATOR){
            this.lOGICOPERATORList = solveNullList(lOGICOPERATOR);
            return this;
        }

        public ConditionBuilder lOGICOPERATORList(List<String> lOGICOPERATOR){
            this.lOGICOPERATORList = lOGICOPERATOR;
            return this;
        }

        public ConditionBuilder rEPORTIDBetWeen(Integer rEPORTIDSt,Integer rEPORTIDEd){
            this.rEPORTIDSt = rEPORTIDSt;
            this.rEPORTIDEd = rEPORTIDEd;
            return this;
        }

        public ConditionBuilder rEPORTIDGreaterEqThan(Integer rEPORTIDSt){
            this.rEPORTIDSt = rEPORTIDSt;
            return this;
        }
        public ConditionBuilder rEPORTIDLessEqThan(Integer rEPORTIDEd){
            this.rEPORTIDEd = rEPORTIDEd;
            return this;
        }


        public ConditionBuilder rEPORTIDList(Integer ... rEPORTID){
            this.rEPORTIDList = solveNullList(rEPORTID);
            return this;
        }

        public ConditionBuilder rEPORTIDList(List<Integer> rEPORTID){
            this.rEPORTIDList = rEPORTID;
            return this;
        }

        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public ConditionBuilder build(){return this;}
    }

    public static class Builder {

        private REPORTCRITERIA obj;

        public Builder(){
            this.obj = new REPORTCRITERIA();
        }

        public Builder ID(Integer ID){
            this.obj.setID(ID);
            return this;
        }
        public Builder cOLUMNNAME(String cOLUMNNAME){
            this.obj.setCOLUMNNAME(cOLUMNNAME);
            return this;
        }
        public Builder cOMPAREOPERATOR(String cOMPAREOPERATOR){
            this.obj.setCOMPAREOPERATOR(cOMPAREOPERATOR);
            return this;
        }
        public Builder lOGICOPERATOR(String lOGICOPERATOR){
            this.obj.setLOGICOPERATOR(lOGICOPERATOR);
            return this;
        }
        public Builder rEPORTID(Integer rEPORTID){
            this.obj.setREPORTID(rEPORTID);
            return this;
        }
        public REPORTCRITERIA build(){return obj;}
    }

}
